/***********************************************************
* Purpose : update the answer  
* Author : NuoiNV
* Date: 19/1/2012
* Description: update the answer
*/
IF EXISTS ( SELECT * FROM SYSOBJECTS WHERE NAME = 'sp_UpdateAnswer' ) 
BEGIN
	DROP PROC sp_UpdateAnswer
END
GO
CREATE PROC sp_UpdateAnswer

	@ID	int,
	@Question_ID int,
	@Content	VARCHAR(500),
	@Correct  int,
	@RESULT	INT OUTPUT
AS
BEGIN 
	DECLARE @Last_Update	DATETIME
	SET @Last_Update = GETDATE()
	IF EXISTS (SELECT * FROM Answer  WHERE ID = @ID and Question_ID=@Question_ID)
	Begin
		UPDATE Answer 
			
			SET [Content] = @Content,Correct = @Correct, Last_Update= @Last_Update from Answer where [ID] = @ID and Question_ID= @Question_ID
			SET @RESULT = 1
	End
	Else
		Begin
			SET @RESULT = 0
		End
END 